from rest_framework import serializers
from .models import Vehicle, VehicleImage,VehicleViolation

class VehicleSerializer(serializers.ModelSerializer):
    class Meta:
        model = Vehicle
        fields = '__all__'

class VehicleUpdateSerializer(serializers.ModelSerializer):
    """车辆更新序列化器，user_id字段不是必填的"""
    user_id = serializers.IntegerField(required=False)

    class Meta:
        model = Vehicle
        fields = ['plate_number', 'model', 'color', 'user_id']

class VehicleImageSerializer(serializers.ModelSerializer):
    class Meta:
        model = VehicleImage
        fields = '__all__'
class VehicleViolationSerializer(serializers.ModelSerializer):
    class Meta:
        model = VehicleViolation
        fields = '__all__'